home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / LITTLE / BMSRC.ZIP / IO.S < prev    next >
Encoding:
Text File  |  1996-11-24  |  40.6 KB  |  1,541 lines

  1. *=======================================================*
  2. *    IO routines: latest update 25/03/96        *
  3. *=======================================================*
  4. *    Handle all WAD related processes        *
  5. *=======================================================*
  6.  
  7.     include        include\wad_tab.s
  8.     
  9. *-------------------------------------------------------*
  10. parse_cli:
  11. *-------------------------------------------------------*
  12.     moveq        #0,d0
  13. *-------------------------------------------------------*
  14.     ifnd        test
  15. *-------------------------------------------------------*
  16.     move.l        cli,a4
  17.     move.b        (a4)+,d0
  18.     beq        safe_quit
  19. *-------------------------------------------------------*
  20.     elseif
  21. *-------------------------------------------------------*
  22.     lea        default_path,a4
  23.     move.b        #255,d0
  24. *-------------------------------------------------------*
  25.     endc
  26. *-------------------------------------------------------*    
  27.     lea        cli_space,a5
  28.     clr.b        (a4,d0.l)
  29. .all:    move.b        (a4)+,(a5)+
  30.     bne.s        .all
  31. *-------------------------------------------------------*
  32.     lea        levelmarker,a0
  33.     move.l        #-1,(a0)
  34. *-------------------------------------------------------*
  35. *    Parse new CLI                    *
  36. *-------------------------------------------------------*
  37.     bsr        parse_new_cli
  38. *-------------------------------------------------------*
  39.     tst.b        iwad_path
  40.     bne.s        .not_old_cli
  41. *-------------------------------------------------------*
  42. *    Parse old CLI if new format not detected    *
  43. *-------------------------------------------------------*
  44.     bsr        parse_old_cli
  45. *-------------------------------------------------------*
  46. .not_old_cli:
  47. *-------------------------------------------------------*
  48.     rts
  49.  
  50. *-------------------------------------------------------*
  51. parse_new_cli:
  52. *-------------------------------------------------------*
  53.     lea        cli_space,a5
  54. *-------------------------------------------------------*
  55. *    Check for last character            *
  56. *-------------------------------------------------------*
  57. .nwad:    move.b        (a5)+,d1
  58.     beq        .adon
  59.     fixcase        d1
  60. *-------------------------------------------------------*
  61. *    Check for option                *
  62. *-------------------------------------------------------*
  63.     cmp.b        #'-',d1
  64.     bne        .odon
  65. *-------------------------------------------------------*
  66. *    Check for new IWAD path                * 
  67. *-------------------------------------------------------*
  68.     lea        ascii_iwad_switch,a0
  69.     bsr        check_switch
  70.     tst.l        d0
  71.     bmi.s        .niwad
  72.     lea        iwad_path,a1
  73.     move.w        #255,d7
  74.     bsr        load_parameter
  75.     bra.s        .odon
  76. *-------------------------------------------------------*
  77. *    Check for new PWAD path                * 
  78. *-------------------------------------------------------*
  79. .niwad:    lea        ascii_pwad_switch,a0
  80.     bsr        check_switch
  81.     tst.l        d0
  82.     bmi.s        .npwad
  83.     lea        pwad_path,a1
  84.     move.w        #255,d7
  85.     bsr        load_parameter
  86.     bra.s        .odon
  87. *-------------------------------------------------------*
  88. *    Check for 'warp' level select            *
  89. *-------------------------------------------------------*
  90. .npwad:    lea        ascii_warp_switch,a0
  91.     bsr        check_switch
  92.     tst.l        d0
  93.     bmi.s        .odon
  94.     lea        levelmarker,a1
  95.     moveq        #8,d7
  96.     bsr        load_parameter
  97. *-------------------------------------------------------*
  98. *    Continue until CLI exhausted            *
  99. *-------------------------------------------------------*
  100. .odon:    bra        .nwad
  101. *-------------------------------------------------------*
  102. .adon:    rts
  103.  
  104. *-------------------------------------------------------*
  105. load_parameter:
  106. *-------------------------------------------------------*
  107.     move.l        a5,a2
  108.     bsr        skip_padding
  109. *-------------------------------------------------------*
  110. .next:    move.b        (a2)+,d1
  111.     beq.s        .done
  112. *-------------------------------------------------------*
  113.     fixcase        d1
  114.     cmp.b        #'.',d1
  115.     blo.s        .done
  116.     cmp.b        #'z',d1
  117.     bhi.s        .done
  118.     move.b        d1,(a1)+
  119.     bra.s        .next
  120. *-------------------------------------------------------*
  121. .done:    clr.b        (a1)
  122.     rts
  123.     
  124. *-------------------------------------------------------*
  125. skip_padding:
  126. *-------------------------------------------------------*
  127. .next:    move.b        (a2)+,d1
  128.     beq.s        .err
  129.     fixcase        d1
  130.     cmp.b        #'.',d1
  131.     blo.s        .next
  132.     cmp.b        #'z',d1
  133.     bhi.s        .next
  134. .err:    subq.l        #1,a2
  135.     rts
  136.  
  137. *-------------------------------------------------------*
  138. check_switch:
  139. *-------------------------------------------------------*
  140.     move.l        a5,a4
  141. *-------------------------------------------------------*
  142. .next:    move.b        (a0),d0
  143.     move.b        (a4),d4
  144.     fixcase        d0
  145.     fixcase        d4
  146.     cmp.b        #'.',d0
  147.     blo.s        .done
  148.     cmp.b        #'z',d0
  149.     bhi.s        .done
  150.     cmp.b        #'.',d4
  151.     blo.s        .done
  152.     cmp.b        #'z',d4
  153.     bhi.s        .done
  154. *-------------------------------------------------------*
  155.     cmp.b        d0,d4
  156.     bne.s        .err
  157. *-------------------------------------------------------*
  158.     addq.l        #1,a0
  159.     addq.l        #1,a4
  160.     bra.s        .next
  161. *-------------------------------------------------------*
  162. .err:    moveq        #-1,d0
  163.     bra.s        .exit
  164. *-------------------------------------------------------*
  165. .done:    move.l        a4,a5
  166.     moveq        #0,d0
  167. .exit:    rts
  168.     
  169. *-------------------------------------------------------*
  170. parse_old_cli:
  171. *-------------------------------------------------------*
  172.     lea        cli_space,a5
  173. *-------------------------------------------------------*
  174. *    Parse options                    *
  175. *-------------------------------------------------------*
  176. .load:    lea        iwad_path,a0
  177.     lea        levelmarker,a2
  178. *-------------------------------------------------------*
  179. *    Check for last character            *
  180. *-------------------------------------------------------*
  181. .nwad:    move.b        (a5)+,d1
  182.     beq.s        .adon
  183.     fixcase        d1
  184.     cmp.b        #' ',d1
  185.     beq.s        .nlwad
  186.     move.b        d1,(a0)+
  187.     bra.s        .nwad
  188. *-------------------------------------------------------*
  189. .nlwad:    move.b        (a5)+,d1
  190.     beq.s        .done
  191.     fixcase        d1
  192.     move.b        d1,(a2)+
  193.     bra.s        .nlwad
  194. .done:    clr.b        (a2)
  195. *-------------------------------------------------------*
  196. *    Terminate IWAD path string            *
  197. *-------------------------------------------------------*
  198. .adon:    clr.b        (a0)
  199.     rts
  200.  
  201. *-------------------------------------------------------*
  202. *    Read details from IWAD                *
  203. *-------------------------------------------------------*
  204. parse_iwad:
  205. *-------------------------------------------------------*
  206.     Cconws        #ascii_startup
  207.     bsr        open_wad
  208.     tst.w        d0
  209.     bmi        err_openwad
  210. .wad_check:
  211.     lea        wad_header,a5
  212.     Fread        wad_handle,#wh_len,a5
  213.     move.l        wh_sig(a5),d0
  214.     cmp.l        #'IWAD',d0
  215.     bne        err_badwad
  216. .sig_valid:
  217.     move.l        d0,wad_signature
  218.     Cconws        #ascii_format1
  219.     Cconws        #wad_signature
  220.     imov.l        wh_entries(a5),d1
  221.     move.l        d1,wad_entries
  222.     tst.l        d1
  223.     beq        err_badwad
  224.     imov.l        wh_directory(a5),wad_diroffset
  225.     Cconws        #ascii_entries
  226.     move.l        wad_entries,d0
  227.     moveq        #0,d1
  228.     bsr        output_decimal
  229.     Fseek        wad_diroffset,wad_handle,#0
  230.     bsr        wad_readall
  231.     rts    
  232.  
  233. *-------------------------------------------------------*
  234. *    Read details from PWAD                *
  235. *-------------------------------------------------------*
  236. parse_pwad:
  237. *-------------------------------------------------------*
  238.     tst.b        pwad_path
  239.     beq        .no_pwad
  240. *-------------------------------------------------------*
  241.     bsr        open_pwad
  242.     tst.w        d0
  243.     bmi        err_openwad
  244. .wad_check:
  245.     lea        pwad_header,a5
  246.     Fread        pwad_handle,#wh_len,a5
  247.     move.l        wh_sig(a5),d0
  248.     cmp.l        #'PWAD',d0
  249.     bne        err_badpwad
  250. .sig_valid:
  251.     move.l        d0,pwad_signature
  252.     Cconws        #ascii_format2
  253.     Cconws        #pwad_signature
  254.     imov.l        wh_entries(a5),d1
  255.     move.l        d1,pwad_entries
  256.     tst.l        d1
  257.     beq        err_badpwad
  258.     imov.l        wh_directory(a5),pwad_diroffset
  259.     Cconws        #ascii_entries
  260.     move.l        pwad_entries,d0
  261.     moveq        #0,d1
  262.     bsr        output_decimal
  263.     Fseek        pwad_diroffset,pwad_handle,#0
  264.     bsr        pwad_readall
  265. *-------------------------------------------------------*
  266. .no_pwad:
  267. *-------------------------------------------------------*
  268.     rts    
  269.  
  270. *-------------------------------------------------------*
  271. *    Integrate PWAD directory into main        *
  272. *-------------------------------------------------------*
  273. integrate_wads:
  274. *-------------------------------------------------------*
  275.     tst.b        pwad_path
  276.     beq        .no_pwad
  277. *-------------------------------------------------------*
  278. *    Build quick-search hastable for IWAD        *
  279. *-------------------------------------------------------*
  280.     bsr        build_directory_hash
  281.     Cconws        #ascii_integrate
  282. *-------------------------------------------------------*
  283. *    Integrate each new entry into main        *
  284. *-------------------------------------------------------*
  285.     move.l        pwad_directory,a3
  286.     move.l        pwad_entries,d7
  287.     bra        .go
  288. *-------------------------------------------------------*
  289. .all:    lea        wd_name(a3),a0    
  290.     bsr        locate_entry
  291.     tst.l        d0
  292.     beq.s        .append_entry
  293. *-------------------------------------------------------*
  294. .patch_entry:
  295. *-------------------------------------------------------*
  296. *    Patch entry over main directory            *
  297. *-------------------------------------------------------*
  298.     move.l        d0,a4
  299.     moveq        #0,d6
  300.     bra.s        .check_type
  301. *-------------------------------------------------------*
  302. .append_entry:
  303. *-------------------------------------------------------*
  304. *    Append entry to main directory            *
  305. *-------------------------------------------------------*
  306.     move.l        all_directory,a4
  307.     move.l        wad_entries,d1
  308.     mulu.l        #wd_len,d1
  309.     add.l        d1,a4
  310.     moveq        #1,d6
  311. *-------------------------------------------------------*
  312. *    Check entry size (could be a whole group)    *
  313. *-------------------------------------------------------*
  314. .check_type:
  315. *-------------------------------------------------------*
  316.     lea        wd_name(a3),a0    
  317. *-------------------------------------------------------*
  318. *    Check for Doom level marker            *
  319. *-------------------------------------------------------*
  320.     lea        ascii_mask_exmx,a1
  321.     bsr        strcmp_8_wild
  322.     tst.w        d0
  323.     bne.s        .level_group
  324. *-------------------------------------------------------*
  325. *    Check for Doom II level marker            *
  326. *-------------------------------------------------------*
  327.     lea        ascii_mask_mapxx,a1
  328.     bsr        strcmp_8_wild
  329.     tst.w        d0
  330.     bne.s        .level_group
  331. *-------------------------------------------------------*
  332. *    Entry is a singular element            *
  333. *-------------------------------------------------------*
  334. .single_entry:
  335. *-------------------------------------------------------*
  336.     move.l        a4,a2
  337.     move.l        a3,a0
  338.     moveq        #(wd_len/4)-1,d0
  339. .copy:    move.l        (a0)+,(a2)+
  340.     dbra        d0,.copy
  341. *-------------------------------------------------------*
  342. *    Mark entry as PWAD resource            *
  343. *-------------------------------------------------------*
  344.     bset        #7,wd_offset(a4)
  345. *-------------------------------------------------------*
  346. *    Advance to next entry                *
  347. *-------------------------------------------------------*
  348.     add.l        d6,all_entries
  349.     lea        wd_len(a3),a3
  350. *-------------------------------------------------------*
  351.     bra.s        .entry_done
  352. *-------------------------------------------------------*
  353. *    Entry is a group of elements            *
  354. *-------------------------------------------------------*
  355. .level_group:
  356. *-------------------------------------------------------*
  357. .element_loop:
  358. *-------------------------------------------------------*
  359.     move.l        a4,a2
  360.     move.l        a3,a0
  361.     moveq        #(wd_len/4)-1,d0
  362. .copy1:    move.l        (a0)+,(a2)+
  363.     dbra        d0,.copy1
  364. *-------------------------------------------------------*
  365. *    Mark entry as PWAD resource            *
  366. *-------------------------------------------------------*
  367.     bset        #7,wd_offset(a4)
  368. *-------------------------------------------------------*
  369. *    Advance to next entry                *
  370. *-------------------------------------------------------*
  371.     add.l        d6,all_entries
  372.     lea        wd_len(a4),a4
  373.     lea        wd_len(a3),a3
  374. *-------------------------------------------------------*
  375. *    Continue until entry not recognised        *
  376. *-------------------------------------------------------*
  377.     lea        level_fieldlist,a2
  378.     lea        wd_name(a3),a0
  379. .next:    move.l        0(a2),d0
  380.     lea        8(a2),a2
  381.     tst.l        d0
  382.     ble.s        .entry_done
  383.     move.l        d0,a1
  384.     bsr        strcmp_8
  385.     tst.w        d0
  386.     beq.s        .next
  387. *-------------------------------------------------------*
  388.     bra.s        .element_loop
  389. *-------------------------------------------------------*
  390. .entry_done:
  391. *-------------------------------------------------------*
  392. .go:    dbra        d7,.all
  393. *-------------------------------------------------------*
  394. .no_pwad:
  395. *-------------------------------------------------------*
  396.     rts
  397.  
  398. *-------------------------------------------------------*
  399. *    Create hashtable to reduce search overheads    *
  400. *-------------------------------------------------------*
  401. build_directory_hash:
  402. *-------------------------------------------------------*
  403. *    Create hashtable for all valid entries        *
  404. *-------------------------------------------------------*
  405. .cont:    bsr        empty_hash
  406.     move.l        all_directory,a0
  407.     move.l        all_entries,d7
  408.     move.l        hash_array,a2
  409.     bra.s        .go
  410. *-------------------------------------------------------*
  411. *    Generate hash index for entry            *
  412. *-------------------------------------------------------*
  413. .all:    lea        wd_name(a0),a1
  414.     bsr        hash_name
  415. *-------------------------------------------------------*
  416. *    Store reference in hash table            *
  417. *-------------------------------------------------------*
  418.     move.w        #max_hash-1,d4
  419. .find:    and.w        #max_hash-1,d1
  420.     tst.l        (a2,d1.w*4)
  421.     beq.s        .slot
  422.     addq.w        #1,d1
  423.     dbra        d4,.find
  424. .slot:    move.l        a0,(a2,d1.w*4)
  425. *-------------------------------------------------------*
  426.     lea        wd_len(a0),a0
  427. .go:    dbra        d7,.all
  428. .exit:    rts
  429.  
  430. *-------------------------------------------------------*
  431. *    Track down one entry in directory        *
  432. *-------------------------------------------------------*
  433. locate_entry:    
  434. *-------------------------------------------------------*
  435.     move.l        a0,a1
  436.     bsr        hash_name
  437.     move.l        hash_array,a2
  438.     move.w        #max_hash-1,d4
  439. .find:    and.w        #max_hash-1,d1
  440.     move.l        (a2,d1.w*4),d5
  441.     beq.s        .err
  442.     move.l        d5,a1
  443.     lea        wd_name(a1),a1
  444.     bsr        strcmp_8
  445.     tst.w        d0
  446.     beq.s        .cont
  447.     move.l        d5,d0
  448.     bra.s        .exit
  449. .cont:    addq.w        #1,d1
  450.     dbra        d4,.find
  451. .err:    moveq        #0,d0
  452. .exit:    rts
  453.  
  454. *-------------------------------------------------------*
  455. *    Read all IWAD directory entries            *
  456. *-------------------------------------------------------*
  457. wad_readall:
  458. *-------------------------------------------------------*
  459.     move.l        #max_wad_entries,d0
  460.     mulu.l        #wd_len,d0
  461.     move.l        d0,d7
  462.     moveq        #VRAM_preferred,d1
  463.     bsr        allocate_chunk
  464.     tst.l        d0
  465.     ble        err_memory
  466.     move.l        d0,wad_directory
  467.     Fread        wad_handle,d7,d0
  468. .reformat_directory:
  469.     move.l        wad_directory,a0
  470.     move.l        wad_entries,d7
  471. .reformat_next:
  472.     imov.l        wd_offset(a0),wd_offset(a0)
  473.     imov.l        wd_size(a0),wd_size(a0)
  474.     lea        wd_len(a0),a0
  475.     subq.l        #1,d7
  476.     bne.s        .reformat_next
  477. *-------------------------------------------------------*
  478. *    Prepare to merge IWAD & PWAD directories    *
  479. *-------------------------------------------------------*
  480.     move.l        wad_entries,all_entries
  481.     move.l        wad_directory,all_directory
  482. *-------------------------------------------------------*
  483.     rts
  484.  
  485. *-------------------------------------------------------*
  486. *    Read all PWAD directory entries            *
  487. *-------------------------------------------------------*
  488. pwad_readall:
  489. *-------------------------------------------------------*
  490.     move.l        pwad_entries,d0
  491.     mulu.l        #wd_len,d0
  492.     move.l        d0,d7
  493.     moveq        #VRAM_preferred,d1
  494.     bsr        allocate_chunk
  495.     tst.l        d0
  496.     ble        err_memory
  497.     move.l        d0,pwad_directory
  498.     Fread        pwad_handle,d7,d0
  499. .reformat_directory:
  500.     move.l        pwad_directory,a0
  501.     move.l        pwad_entries,d7
  502. .reformat_next:
  503.     imov.l        wd_offset(a0),wd_offset(a0)
  504.     imov.l        wd_size(a0),wd_size(a0)
  505.     lea        wd_len(a0),a0
  506.     subq.l        #1,d7
  507.     bne.s        .reformat_next
  508.     rts
  509.     
  510. *-------------------------------------------------------*
  511. *    Load & format all level-critical information    *
  512. *-------------------------------------------------------*
  513. load_leveldata:
  514. *-------------------------------------------------------*
  515.     move.l        all_directory,wad_mdirectory
  516.     move.l        all_entries,wad_mentries    
  517.     lea        levelmarker,a0
  518.     cmp.l        #-1,(a0)
  519.     beq.s        .use_default
  520.     bsr        place_marker
  521.     tst.l        d0
  522.     beq        err_missing
  523.     push.l        a0
  524.     move.l        a0,d7
  525.     Cconws        #ascii_levelmark
  526.     Cconws        d7
  527.     Cconws        #ascii_newline
  528.     pop.l        a0    
  529. .use_default:
  530.     bsr        init_fields
  531.     move.l        wad_mentries,d7
  532.     beq        err_fields
  533.     cmp.l        #32,d7
  534.     bmi.s        .clip_search
  535.     moveq        #32,d7
  536. .clip_search:
  537.     move.l        wad_mdirectory,a1
  538.     move.w        #field_count,fields_left
  539. .next_entry:
  540.     tst.w        fields_left
  541.     beq.s        .fields_done
  542.     lea        wd_name(a1),a0
  543.     bsr        check_fields
  544.     lea        wd_len(a1),a1
  545.     subq.l        #1,d7
  546.     bne.s        .next_entry
  547.     tst.w        fields_left
  548.     beq.s        .fields_done
  549.     bra        err_fields
  550. .fields_done:
  551.     bsr        measure_linedefs
  552.     Cconws        #ascii_parsingdone
  553.     rts
  554.  
  555. *-------------------------------------------------------*
  556. *    Calculate length of all walls for mapping    *    
  557. *-------------------------------------------------------*
  558. measure_linedefs:
  559. *-------------------------------------------------------*
  560.     move.l        Seg_Array,a0
  561.     move.l        Vertex_Array,a1
  562.     move.l        Line_Array,a2
  563.     move.w        NumSegs,d0
  564.     bra.s        .go
  565. .lp:    moveq        #0,d1
  566.     move.w        seg_from(a0),d1
  567.     moveq        #0,d2
  568.     move.w        seg_to(a0),d2
  569.     move.w        vtx_x(a1,d1.l*4),d3
  570.     move.w        vtx_y(a1,d1.l*4),d4
  571.     move.w        vtx_x(a1,d2.l*4),d5
  572.     move.w        vtx_y(a1,d2.l*4),d6
  573.     sub.w        d3,d5
  574.     sub.w        d4,d6
  575.     muls.w        d5,d5
  576.     muls.w        d6,d6
  577.     add.l        d5,d6
  578.     bsr        square_root
  579.     move.l        d7,seg_length(a0)        ; temporarily use BAM field for length
  580.     lea        seg_len(a0),a0
  581. .go:    dbra        d0,.lp
  582.     rts
  583.  
  584. *-------------------------------------------------------*
  585. *    Simple subdivisional 16.16 sqrt routine        *
  586. *-------------------------------------------------------*
  587. square_root:
  588. *-------------------------------------------------------*
  589.     tst.l        d6
  590.     bpl.s        .pos
  591.     neg.l        d6
  592. .pos:    move.l        #1<<(32-1),d7
  593.     move.l        #1<<(32-2),d5
  594. .loop:    move.l        d7,d3
  595.     mulu.l        d3,d4:d3
  596.     cmp.l        d6,d4
  597.     bgt.s        .sub
  598.     blt.s        .add
  599. .done:    rts
  600. .add:    add.l        d5,d7
  601.     lsr.l        d5
  602.     bne.s        .loop
  603.     bra.s        .done
  604. .sub:    sub.l        d5,d7
  605.     lsr.l        d5
  606.     bne.s        .loop
  607.     bra.s        .done
  608.  
  609. *-------------------------------------------------------*
  610. *    Set up all leveldata search fields        *
  611. *-------------------------------------------------------*
  612. init_fields:
  613. *-------------------------------------------------------*
  614.     lea        level_fieldlist,a0
  615.     lea        level_fields,a1
  616.     moveq        #field_count-1,d2
  617. .next:    move.l        field_ascii(a0),(a1)+
  618.     lea        field_len(a0),a0
  619.     dbra        d2,.next
  620.     move.l        #-1,(a1)
  621.     rts
  622.  
  623. *-------------------------------------------------------*
  624. *    Hunt down and load each level resource        *
  625. *-------------------------------------------------------*
  626. check_fields:
  627. *-------------------------------------------------------*
  628.     lea        level_fields,a6
  629.     lea        level_fieldlist-field_len,a5
  630. .next:    lea        field_len(a5),a5
  631.     move.l        (a6)+,d0
  632.     bmi        .check_done
  633.     beq.s        .next
  634.     move.l        d0,a2
  635.     move.l        a0,a3
  636. .cmpl:    move.b        (a2)+,d2
  637.     beq.s        .same
  638.     fixcase        d2
  639.     move.b        (a3)+,d3
  640.     fixcase        d3
  641.     cmp.b        d2,d3
  642.     beq.s        .cmpl
  643. .diff:    bra.s        .next
  644. .same:    pushall
  645.     move.l        a1,a4
  646.     move.l        d0,d7
  647.     Cconws        #ascii_reading
  648.     Cconws        d7
  649.     Cconws        #ascii_wipe
  650.     move.l        wd_size(a4),d0
  651.     addq.l        #3,d0
  652.     and.b        #-4,d0
  653.     moveq        #VRAM_preferred,d1
  654.     bsr        allocate_chunk
  655.     tst.l        d0
  656.     ble        .err_memory
  657.     move.l        d0,field_ptr
  658. *-------------------------------------------------------*
  659. *    Read from IWAD or PWAD depending on flag    *
  660. *-------------------------------------------------------*
  661.     move.l        wd_offset(a4),d0
  662.     bclr        #31,d0
  663.     bne.s        .pwad
  664. .iwad:    Fseek        d0,wad_handle,#0
  665.     Fread        wad_handle,wd_size(a4),field_ptr
  666.     bra.s        .rdon
  667. .pwad:    Fseek        d0,pwad_handle,#0
  668.     Fread        pwad_handle,wd_size(a4),field_ptr
  669. *-------------------------------------------------------*
  670. .rdon:    tst.l        d0
  671.     bmi        .err_truncated        
  672.     move.l        field_module(a5),a2
  673.     move.l        wd_size(a4),d0
  674.     jsr        (a2)
  675.     move.l        field_ptr,d0
  676.     bsr        deallocate_chunk
  677.     popall
  678.     subq.w        #1,fields_left
  679.     clr.l        -4(a6)
  680. .check_done:
  681.     rts
  682. .err_memory:
  683.     popall
  684.     bra        err_memory
  685. .err_truncated:
  686.     popall
  687.     bra        err_truncated
  688.     
  689. *-------------------------------------------------------*
  690. *    Place search-marker in WAD directory        *
  691. *-------------------------------------------------------*
  692. place_marker:
  693. *-------------------------------------------------------*
  694.     move.l        a0,wad_searchfield
  695.     move.l        all_directory,a1
  696.     move.l        all_entries,d1
  697. .search_next:
  698.     lea        wd_name(a1),a2
  699.     move.l        a0,a3
  700.     moveq        #8-1,d4
  701. .search_look:
  702.     move.b        (a3)+,d2
  703.     beq.s        .search_stop
  704.     fixcase        d2
  705.     move.b        (a2)+,d3
  706.     fixcase        d3
  707.     cmp.b        d2,d3    
  708.     bne.s        .search_diff
  709.     dbra        d4,.search_look
  710.     bra.s        .search_over
  711. .search_diff:    
  712.     lea        wd_len(a1),a1
  713.     subq.l        #1,d1
  714.     bne.s        .search_next
  715. .search_fail:
  716.     moveq        #0,d0
  717.     bra.s        .search_exit
  718. .search_stop:
  719.     tst.b        (a2)+
  720.     bne.s        .search_diff
  721. .search_over:
  722.     move.l        a1,wad_mdirectory
  723.     move.l        d1,wad_mentries
  724.     moveq        #1,d0
  725. .search_exit:
  726.     rts
  727.  
  728. *-------------------------------------------------------*
  729. *    Find & load any resource from WAD        *
  730. *-------------------------------------------------------*
  731. load_resource:
  732. *-------------------------------------------------------*
  733.     move.l        a0,wad_searchfield
  734.     move.l        all_directory,a1
  735.     move.l        all_entries,d1
  736. .search_next:
  737.     lea        wd_name(a1),a2
  738.     move.l        a0,a3
  739.     moveq        #8-1,d4
  740. .search_look:
  741.     move.b        (a3)+,d2
  742.     beq.s        .search_stop
  743.     fixcase        d2
  744.     move.b        (a2)+,d3
  745.     fixcase        d3
  746.     cmp.b        d2,d3    
  747.     bne.s        .search_diff
  748.     dbra        d4,.search_look
  749.     bra.s        .search_over
  750. .search_diff:    
  751.     lea        wd_len(a1),a1
  752.     subq.l        #1,d1
  753.     bne.s        .search_next
  754. .search_fail:
  755.     moveq        #0,d0
  756.     bra        .search_exit
  757. .search_stop:
  758.     tst.b        (a2)+
  759.     bne.s        .search_diff
  760. .search_over:
  761.     move.l        a1,wad_mdirectory
  762.     move.l        wd_size(a1),d6
  763.     move.l        d6,d0
  764.     moveq        #VRAM_preferred,d1
  765.     bsr        allocate_chunk
  766.     tst.l        d0
  767.     ble.s        .search_fail
  768.     move.l        d0,a6
  769.     move.l        a1,a4
  770.     pushall
  771. *-------------------------------------------------------*
  772. *    Read from IWAD or PWAD depending on flag    *
  773. *-------------------------------------------------------*
  774.     move.l        wd_offset(a4),d0
  775.     bclr        #31,d0
  776.     bne.s        .pwad
  777. .iwad:    Fseek        d0,wad_handle,#0
  778.     Fread        wad_handle,wd_size(a4),a6
  779.     bra.s        .rdon
  780. .pwad:    Fseek        d0,pwad_handle,#0
  781.     Fread        pwad_handle,wd_size(a4),a6
  782. *-------------------------------------------------------*
  783. .rdon    popall
  784.     moveq        #1,d0
  785. .search_exit:
  786.     rts
  787.  
  788. *-------------------------------------------------------*
  789. *    Direct-access version of load_resource        *
  790. *-------------------------------------------------------*
  791. read_resource:
  792. *-------------------------------------------------------*
  793.     pushall
  794.     move.l        a0,a4
  795.     move.l        a1,a6
  796.     move.l        wd_size(a4),d6
  797. *-------------------------------------------------------*
  798. *    Read from IWAD or PWAD depending on flag    *
  799. *-------------------------------------------------------*
  800.     move.l        wd_offset(a4),d0
  801.     bclr        #31,d0
  802.     bne.s        .pwad
  803. .iwad:    Fseek        d0,wad_handle,#0
  804.     Fread        wad_handle,wd_size(a4),a6
  805.     bra.s        .rdon
  806. .pwad:    Fseek        d0,pwad_handle,#0
  807.     Fread        pwad_handle,wd_size(a4),a6
  808. *-------------------------------------------------------*
  809. .rdon:    popall
  810.     rts
  811.  
  812. *-------------------------------------------------------*
  813. *    Open IWAD file for work                *
  814. *-------------------------------------------------------*
  815. open_wad:
  816. *-------------------------------------------------------*
  817.     movem.l        d1-a6,-(sp)
  818.     tst.w        wad_handle
  819.     bne.s        .open
  820.     Fopen        #iwad_path,#0
  821.     tst.w        d0
  822.     bmi.s        .open
  823.     move.w        d0,wad_handle
  824. .open:    movem.l        (sp)+,d1-a6
  825.     rts
  826.  
  827. *-------------------------------------------------------*
  828. *    Open PWAD file for work                *
  829. *-------------------------------------------------------*
  830. open_pwad:
  831. *-------------------------------------------------------*
  832.     movem.l        d1-a6,-(sp)
  833.     tst.w        pwad_handle
  834.     bne.s        .open
  835.     Fopen        #pwad_path,#0
  836.     tst.w        d0
  837.     bmi.s        .open
  838.     move.w        d0,pwad_handle
  839. .open:    movem.l        (sp)+,d1-a6
  840.     rts
  841.     
  842. *-------------------------------------------------------*
  843. *    Close IWAD if already open            *
  844. *-------------------------------------------------------*
  845. close_wad:
  846. *-------------------------------------------------------*
  847.     movem.l        d1-a6,-(sp)
  848.     tst.w        wad_handle
  849.     beq.s        .ic
  850.     Fclose        wad_handle
  851.     clr.w        wad_handle
  852. .ic    movem.l        (sp)+,d1-a6
  853.     rts
  854.  
  855. *-------------------------------------------------------*
  856. *    Close PWAD if already open            *
  857. *-------------------------------------------------------*
  858. close_pwad:
  859. *-------------------------------------------------------*
  860.     movem.l        d1-a6,-(sp)
  861.     tst.w        pwad_handle
  862.     beq.s        .pc
  863.     Fclose        pwad_handle
  864.     clr.w        pwad_handle
  865. .pc:    movem.l        (sp)+,d1-a6
  866.     rts
  867.  
  868. *-------------------------------------------------------*
  869. *    Print decimal number to TOS console        *
  870. *-------------------------------------------------------*
  871. output_decimal:
  872. *-------------------------------------------------------*
  873.     lea        stringspace,a0
  874.     moveq        #'0',d2
  875.     moveq        #10,d3
  876. .build:    moveq        #0,d5
  877.     divu.l        d3,d5:d0
  878.     add.w        d2,d5
  879.     move.b        d5,-(a0)
  880.     subq.l        #1,d1
  881.     bgt.s        .build
  882.     tst.l        d0
  883.     bne.s        .build
  884.     Cconws        a0
  885.     rts
  886.  
  887. *-------------------------------------------------------*
  888. *    Load & reformat 'things'            *
  889. *-------------------------------------------------------*
  890. things_module:
  891. *-------------------------------------------------------*
  892.     divu.l        #Thing_len,d0
  893.     move.w        d0,NumThings
  894.     move.w        d0,d7
  895.     mulu.w        #Thing_len,d0
  896.     moveq        #VRAM_preferred,d1
  897.     bsr        allocate_chunk
  898.     tst.l        d0
  899.     ble        error_alloc
  900.     move.l        d0,Thing_Array
  901.     move.l        d0,a1
  902.     move.l        field_ptr,a0
  903.     bra.s        .next_thing    
  904. .thing_loop:
  905.     imov.w        Thing_type(a0),d1
  906.     cmp.w        #1,d1
  907.     bne.s        .no_player
  908.     bsr        .setup_player
  909. .no_player:
  910.     moveq        #(Thing_len/2)-1,d6
  911. .ilp:    imov.w        (a0)+,(a1)+
  912.     dbra        d6,.ilp
  913. .next_thing:
  914.     dbra        d7,.thing_loop
  915.     rts
  916.  
  917. .setup_player:
  918.     imov.w        Thing_x(a0),px
  919.     imov.w        Thing_y(a0),py
  920.     imov.w        Thing_angle(a0),d1
  921.     swap        d1
  922.     clr.w        d1
  923.     divu.w        #360,d1
  924.     move.w        d1,pangle
  925.     rts
  926.  
  927. *-------------------------------------------------------*
  928. *    Load & reformat 'linedefs'            *
  929. *-------------------------------------------------------*
  930. linedefs_module:
  931.     divu.l        #Line_len,d0
  932.     move.w        d0,NumLines
  933.     move.w        d0,d7
  934.     mulu.w        #Line_len,d0
  935.     moveq        #VRAM_preferred,d1
  936.     bsr        allocate_chunk
  937.     tst.l        d0
  938.     ble        error_alloc
  939.     move.l        d0,Line_Array
  940.     move.l        d0,a1
  941.     move.l        field_ptr,a0
  942.     bra.s        .next_line
  943. .line_loop:
  944.     moveq        #(Line_len/2)-1,d6
  945. .ilp:    imov.w        (a0)+,(a1)+
  946.     dbra        d6,.ilp
  947. .next_line:
  948.     dbra        d7,.line_loop
  949.     rts
  950.     
  951. *-------------------------------------------------------*
  952. *    Load & reformat 'sidedefs'            *
  953. *-------------------------------------------------------*
  954. sidedefs_module:
  955. *-------------------------------------------------------*
  956.     divu.l        #Side_len,d0
  957.     move.w        d0,NumSides
  958.     move.w        d0,d7
  959.     mulu.w        #Side_len,d0
  960.     moveq        #VRAM_preferred,d1
  961.     bsr        allocate_chunk
  962.     tst.l        d0
  963.     ble        error_alloc
  964.     move.l        d0,Side_Array
  965.     move.l        d0,a1
  966.     move.l        field_ptr,a0
  967.     bra.s        .next_side
  968. .side_loop:
  969.     imov.w        (a0)+,(a1)+
  970.     imov.w        (a0)+,(a1)+
  971.     move.l        (a0)+,(a1)+
  972.     move.l        (a0)+,(a1)+
  973.     move.l        (a0)+,(a1)+
  974.     move.l        (a0)+,(a1)+
  975.     move.l        (a0)+,(a1)+
  976.     move.l        (a0)+,(a1)+
  977.     imov.w        (a0)+,(a1)+
  978. .next_side:
  979.     dbra        d7,.side_loop
  980.     rts
  981.  
  982. *-------------------------------------------------------*
  983. *    Load & reformat 'vertexes'            *
  984. *-------------------------------------------------------*
  985. vertexes_module:
  986. *-------------------------------------------------------*
  987.     divu.l        #Vertex_len,d0
  988.     move.w        d0,NumVertices
  989.     move.w        d0,d7
  990.     mulu.w        #Vertex_len,d0
  991.     moveq        #VRAM_preferred,d1
  992.     bsr        allocate_chunk
  993.     tst.l        d0
  994.     ble        error_alloc
  995.     move.l        d0,Vertex_Array
  996.     move.l        d0,a1
  997.     move.l        field_ptr,a0
  998.     bra.s        .next_vertex
  999. .vertex_loop:
  1000.     moveq        #(Vertex_len/2)-1,d6
  1001. .ilp:    imov.w        (a0)+,(a1)+
  1002.     dbra        d6,.ilp
  1003. .next_vertex:
  1004.     dbra        d7,.vertex_loop
  1005.     rts
  1006.  
  1007. *-------------------------------------------------------*
  1008. *    Load & reformat 'segs'                *
  1009. *-------------------------------------------------------*
  1010. segs_module:
  1011. *-------------------------------------------------------*
  1012.     divu.l        #Seg_len,d0
  1013.     move.w        d0,NumSegs
  1014.     move.w        d0,d7
  1015.     mulu.w        #seg_len,d0
  1016.     moveq        #VRAM_preferred,d1
  1017.     bsr        allocate_chunk
  1018.     tst.l        d0
  1019.     ble        error_alloc
  1020.     move.l        d0,Seg_Array
  1021.     move.l        d0,a1
  1022.     move.l        field_ptr,a0
  1023.     bra.s        .next_seg
  1024. .seg_loop:
  1025.     moveq        #(Seg_len/2)-1,d6
  1026. .ilp:    imov.w        (a0)+,(a1)+
  1027.     dbra        d6,.ilp
  1028.     addq.l        #4,a1
  1029. .next_seg:
  1030.     dbra        d7,.seg_loop
  1031.     rts
  1032.  
  1033. *-------------------------------------------------------*
  1034. *    Load & reformat 'ssectors'            *
  1035. *-------------------------------------------------------*
  1036. ssectors_module:
  1037. *-------------------------------------------------------*
  1038.     divu.l        #Ssect_len,d0
  1039.     move.w        d0,NumSSectors
  1040.     move.w        d0,d7
  1041.     mulu.w        #Ssect_len,d0
  1042.     moveq        #VRAM_preferred,d1
  1043.     bsr        allocate_chunk
  1044.     tst.l        d0
  1045.     ble        error_alloc
  1046.     move.l        d0,SSector_Array
  1047.     move.l        d0,a1
  1048.     move.l        field_ptr,a0
  1049.     bra.s        .next_ssector
  1050. .ssector_loop:
  1051.     moveq        #(Ssect_len/2)-1,d6
  1052. .ilp:    imov.w        (a0)+,(a1)+
  1053.     dbra        d6,.ilp
  1054. .next_ssector:
  1055.     dbra        d7,.ssector_loop
  1056.     rts
  1057.  
  1058. *-------------------------------------------------------*
  1059. *    Load & reformat 'nodes'                *
  1060. *-------------------------------------------------------*
  1061. nodes_module:
  1062. *-------------------------------------------------------*
  1063.     divu.l        #Node_len,d0
  1064.     move.w        d0,NumNodes
  1065.     move.w        d0,d7
  1066.     mulu.w        #Node_len,d0
  1067.     moveq        #VRAM_preferred,d1
  1068.     bsr        allocate_chunk
  1069.     tst.l        d0
  1070.     ble        error_alloc
  1071.     move.l        d0,Node_Array
  1072.     move.l        d0,a1
  1073.     move.l        field_ptr,a0
  1074.     bra.s        .next_node
  1075. .node_loop:
  1076.     moveq        #(Node_len/2)-1,d6
  1077. .ilp:    imov.w        (a0)+,(a1)+
  1078.     dbra        d6,.ilp
  1079. .next_node:
  1080.     dbra        d7,.node_loop
  1081. .err:    rts
  1082.  
  1083. *-------------------------------------------------------*
  1084. *    Load & reformat 'sectors'            *
  1085. *-------------------------------------------------------*
  1086. sectors_module:
  1087. *-------------------------------------------------------*
  1088.     divu.l        #Sector_len,d0
  1089.     move.w        d0,NumSectors
  1090.     move.w        d0,d7
  1091.     mulu.w        #Sector_len,d0
  1092.     moveq        #VRAM_preferred,d1
  1093.     bsr        allocate_chunk
  1094.     tst.l        d0
  1095.     ble        error_alloc
  1096.     move.l        d0,Sector_Array
  1097.     move.l        d0,a1
  1098.     move.l        field_ptr,a0
  1099.     bra.s        .next_sector
  1100. .sector_loop:
  1101.     imov.w        (a0)+,(a1)+
  1102.     imov.w        (a0)+,(a1)+
  1103.     move.l        (a0)+,(a1)+
  1104.     move.l        (a0)+,(a1)+
  1105.     move.l        (a0)+,(a1)+
  1106.     move.l        (a0)+,(a1)+
  1107.     imov.w        (a0)+,(a1)+
  1108.     imov.w        (a0)+,(a1)+
  1109.     imov.w        (a0)+,(a1)+
  1110. .next_sector:
  1111.     dbra        d7,.sector_loop
  1112.     rts
  1113.  
  1114. *-------------------------------------------------------*
  1115. *    Load & reformat 'reject'            *
  1116. *-------------------------------------------------------*
  1117. reject_module:
  1118. *-------------------------------------------------------*
  1119.     rts
  1120.  
  1121. *-------------------------------------------------------*
  1122. *    Load & reformat 'blockmap'            *
  1123. *-------------------------------------------------------*
  1124. blockmap_module:
  1125. *-------------------------------------------------------*
  1126.     rts
  1127.  
  1128. error_alloc:
  1129.     Cconws        #ascii_err_pnodes
  1130.     bra        err_closewad
  1131.  
  1132. *-------------------------------------------------------*
  1133. *    Modified strcmp for texture name-searching    *
  1134. *-------------------------------------------------------*
  1135. strcmp_8:
  1136. *-------------------------------------------------------*
  1137.     push.l        a0
  1138.     push.l        a1
  1139.     moveq        #8-1,d2
  1140.     moveq        #0,d0
  1141. .loop:    swap        d2
  1142.     move.b        (a0)+,d3
  1143.     beq.s        .term
  1144.     fixcase        d3
  1145.     move.b        (a1)+,d2
  1146.     fixcase        d2
  1147.     cmp.b        d2,d3
  1148.     bne.s        .diff
  1149.     swap        d2
  1150.     dbra        d2,.loop
  1151.     bra.s        .same
  1152. .term:    tst.b        (a1)+
  1153.     bne.s        .diff
  1154. .same:    moveq        #1,d0
  1155. .diff:    pop.l        a1
  1156.     pop.l        a0
  1157.     rts
  1158.  
  1159. *-------------------------------------------------------*
  1160. *    Modified strcmp for texture name-searching    *
  1161. *-------------------------------------------------------*
  1162. strcmp_8_wild:
  1163. *-------------------------------------------------------*
  1164.     push.l        a0
  1165.     push.l        a1
  1166.     moveq        #8-1,d2
  1167.     moveq        #0,d0
  1168. .loop:    swap        d2
  1169.     move.b        (a0)+,d3
  1170.     beq.s        .term
  1171.     cmp.b        #'?',d3
  1172.     beq.s        .same
  1173.     fixcase        d3
  1174.     move.b        (a1)+,d2
  1175.     cmp.b        #'?',d2
  1176.     beq.s        .same
  1177.     fixcase        d2
  1178.     cmp.b        d2,d3
  1179.     bne.s        .diff
  1180.     swap        d2
  1181.     dbra        d2,.loop
  1182.     bra.s        .same
  1183. .term:    tst.b        (a1)+
  1184.     bne.s        .diff
  1185. .same:    moveq        #1,d0
  1186. .diff:    pop.l        a1
  1187.     pop.l        a0
  1188.     rts
  1189.  
  1190. *-------------------------------------------------------*
  1191. *    Miscellaneous error trapping units        *
  1192. *-------------------------------------------------------*
  1193. *    Can be replaced with generalised error handler    *
  1194. *    at some later stage to reduce complexity.    *
  1195. *-------------------------------------------------------*
  1196.  
  1197. *-------------------------------------------------------*
  1198. err_fields:
  1199. *-------------------------------------------------------*
  1200.     Cconws        #ascii_newline
  1201.     lea        level_fields,a6
  1202.     move.w        #field_count-1,d6
  1203. .loop:    move.l        (a6)+,d7
  1204.     beq.s        .next
  1205.     move.l        d7,a0
  1206.     bsr        entry_missing_e
  1207. .next:    dbra        d6,.loop
  1208.     bra        err_closewad
  1209.  
  1210. *-------------------------------------------------------*
  1211. err_missing:
  1212. *-------------------------------------------------------*
  1213.     Cconws        #ascii_newline
  1214.     move.l        wad_searchfield,a0
  1215.     bsr        entry_missing_e
  1216.     bra        err_closewad
  1217.  
  1218. *-------------------------------------------------------*
  1219. err_truncated:
  1220. *-------------------------------------------------------*
  1221.     Cconws        #ascii_newline
  1222.     move.l        wad_searchfield,a0
  1223.     bsr        entry_truncated
  1224.     bra        err_closewad
  1225.  
  1226. *-------------------------------------------------------*
  1227. err_memory:
  1228. *-------------------------------------------------------*
  1229.     Cconws        #ascii_err_memory
  1230.     bra        err_closewad
  1231.  
  1232. *-------------------------------------------------------*
  1233. err_badwad:
  1234. *-------------------------------------------------------*
  1235.     Cconws        #ascii_err_badwad
  1236.     bra        err_closewad
  1237.  
  1238. *-------------------------------------------------------*
  1239. err_badpwad:
  1240. *-------------------------------------------------------*
  1241.     Cconws        #ascii_err_badpwad
  1242.     bra        err_closewad
  1243.  
  1244. *-------------------------------------------------------*
  1245. err_openwad:
  1246. *-------------------------------------------------------*
  1247.     Cconws        #ascii_err_openwad
  1248.     bra        err_closewad
  1249.  
  1250. *-------------------------------------------------------*
  1251. err_closewad:
  1252. *-------------------------------------------------------*
  1253.     bsr        close_wad
  1254.     bsr        close_pwad
  1255.     Crawcin
  1256.     jmp        safe_quit
  1257.  
  1258. *-------------------------------------------------------*
  1259. entry_missing_w:
  1260. *-------------------------------------------------------*
  1261.     pushall
  1262.     lea        string_space,a1
  1263.     move.l        a1,a6
  1264.     move.l        (a0)+,(a1)+
  1265.     move.l        (a0)+,(a1)+
  1266.     clr.b        (a1)
  1267.     Cconws        #ascii_err_missing1w
  1268.     Cconws        a6
  1269.     Cconws        #ascii_err_missing2w
  1270.     popall
  1271.     rts
  1272.  
  1273. *-------------------------------------------------------*
  1274. entry_missing_e:
  1275. *-------------------------------------------------------*
  1276.     pushall
  1277.     lea        string_space,a1
  1278.     move.l        a1,a6
  1279.     move.l        (a0)+,(a1)+
  1280.     move.l        (a0)+,(a1)+
  1281.     clr.b        (a1)
  1282.     Cconws        #ascii_err_missing1e
  1283.     Cconws        a6
  1284.     Cconws        #ascii_err_missing2e
  1285.     popall
  1286.     rts
  1287.  
  1288. *-------------------------------------------------------*
  1289. entry_truncated:
  1290. *-------------------------------------------------------*
  1291.     pushall
  1292.     lea        string_space,a1
  1293.     move.l        a1,a6
  1294.     move.l        (a0)+,(a1)+
  1295.     move.l        (a0)+,(a1)+
  1296.     clr.b        (a1)
  1297.     Cconws        #ascii_err_trunc1
  1298.     Cconws        a6
  1299.     Cconws        #ascii_err_trunc2
  1300.     popall
  1301.     rts
  1302.  
  1303. check_limits:
  1304.     move.w        num_required,d1
  1305.     cmp.w        num_reserved,d1
  1306.     bgt.s        .err
  1307.     rts
  1308. .err:    Cconws        #ascii_limits1
  1309.     moveq        #0,d0
  1310.     move.w        num_reserved,d0
  1311.     moveq        #1,d1
  1312.     bsr        output_decimal
  1313.     Cconws        #ascii_limits2
  1314.     moveq        #0,d0
  1315.     move.w        num_required,d0
  1316.     moveq        #1,d1
  1317.     bsr        output_decimal
  1318.     bra        err_closewad
  1319.  
  1320. *-------------------------------------------------------*
  1321.             datlong
  1322. *-------------------------------------------------------*
  1323.  
  1324. level_fieldlist:    dc.l    ascii_things,things_module    ; list of leveldata resources
  1325.             dc.l    ascii_nodes,nodes_module
  1326.             dc.l    ascii_sectors,sectors_module
  1327.             dc.l    ascii_ssectors,ssectors_module
  1328.             dc.l    ascii_segs,segs_module
  1329.             dc.l    ascii_linedefs,linedefs_module
  1330.             dc.l    ascii_sidedefs,sidedefs_module
  1331.             dc.l    ascii_vertexes,vertexes_module
  1332.             dc.l    ascii_reject,reject_module
  1333.             dc.l    ascii_blockmap,blockmap_module
  1334.             dc.l    terminator
  1335.  
  1336. wad_signature:        ds.l    1                ; IWAD signature
  1337.             dc.b    0
  1338. pwad_signature:        ds.l    1                ; PWAD signature
  1339.             dc.b    0
  1340.  
  1341. *-------------------------------------------------------*
  1342. *    General ASCII messages follow...        *
  1343. *-------------------------------------------------------*
  1344.  
  1345. ascii_mask_exmx:    dc.b    'e?m?',0
  1346. ascii_mask_mapxx:    dc.b    'map??',0
  1347.  
  1348. ascii_texture1:        dc.b    'texture1',0        ; WAD search details
  1349. ascii_texture2:        dc.b    'texture2',0
  1350. ascii_pnames:        dc.b    'pnames',0
  1351. ascii_sky:        dc.b    'f_sky1',0
  1352. ascii_fstart:        dc.b    'f_start',0
  1353. ascii_fend:        dc.b    'f_end',0
  1354. ascii_pstart:        dc.b    'p_start',0
  1355. ascii_pend:        dc.b    'p_end',0
  1356. ascii_qalpha:        dc.b    'sky1',0
  1357.  
  1358. ascii_sky1:        dc.b    'sky1',0
  1359. ascii_sky2:        dc.b    'sky2',0
  1360. ascii_sky3:        dc.b    'sky3',0
  1361. ascii_sky4:        dc.b    'sky4',0
  1362.  
  1363. ascii_loadflats:    dc.b    13,10
  1364.             dc.b    ' Preloading floor & ceiling textures...',0
  1365. ascii_loadwalls:    dc.b    13,10
  1366.             dc.b    ' Preloading wall textures...',0
  1367. ascii_readpnames:    dc.b    13,10
  1368.             dc.b    ' Reading [pnames] directory...',0
  1369. ascii_readtex1:        dc.b    13,10
  1370.             dc.b    ' Reading [texture1] directory...',0
  1371. ascii_readtex2:        dc.b    13,10
  1372.             dc.b    ' Reading [texture2] directory...',0
  1373. ascii_hashtex:        dc.b    13,10
  1374.             dc.b    ' Generating hashtable...',0
  1375. ascii_replacetex:    dc.b    13,10
  1376.             dc.b    ' Replacing textures...',0
  1377. ascii_replaceflat:    dc.b    13,10
  1378.             dc.b    ' Replacing flats...',0
  1379. ascii_fixsky:        dc.b    13,10
  1380.             dc.b    ' Validating sky sidedefs...',0
  1381. ascii_patchalpha:    dc.b    13,10
  1382.             dc.b    ' Patching quick-alpha textures...',0
  1383. ascii_locatepatch:    dc.b    13,10
  1384.             dc.b    ' Organising patches...',0
  1385. ascii_replacedone:    dc.b    13,10
  1386.             dc.b    13,10
  1387.             dc.b    ' Finished processing textures.',0
  1388. ascii_integrate:    dc.b    13,10
  1389.             dc.b    ' Integrating PWAD...'
  1390.             dc.b    13,10,13,10,0
  1391.  
  1392. ascii_warp_switch:    dc.b    'w',0
  1393. ascii_iwad_switch:    dc.b    'i',0
  1394. ascii_pwad_switch:    dc.b    'p',0
  1395.     
  1396. ascii_signal:        dc.b    13,10,'signal',0
  1397. ascii_newline:        dc.b    13,10,0
  1398. ascii_startup:        dc.b    27,'E',27,'f',13,10
  1399.             dc.b    ' Doom Environment Simulator v2.16alpha.',13,10,13,10
  1400.             dc.b    ' DSP Doom engine by Doug Little.',13,10,0
  1401.  
  1402. ascii_format1:        dc.b    13,10
  1403.             dc.b    ' IWAD check:    ',0
  1404. ascii_format2:        dc.b    13,10
  1405.             dc.b    ' PWAD check:    ',0
  1406.  
  1407. ascii_levelmark:    dc.b    ' Warp to:    ',0
  1408. ascii_reading:        dc.b    13
  1409.             dc.b    ' Reading:    ',0
  1410. ascii_wipe:        dc.b    '        ',0
  1411.  
  1412. ascii_entries:        dc.b    13,10
  1413.             dc.b    ' Directories:    ',0
  1414.  
  1415. ascii_limits1:        dc.b    13,10
  1416.             dc.b    13,10
  1417.             dc.b    ' Too many elements!',13,10
  1418.             dc.b    ' Reserved: ',0
  1419. ascii_limits2:        dc.b    13,10,' Required: ',0
  1420.  
  1421. ascii_entriesdone:    dc.b    13,10,0
  1422.  
  1423. ascii_parsingdone:    dc.b    13,10
  1424.             dc.b    13,10
  1425.             dc.b    ' Finished processing leveldata.',13,10,0 
  1426.  
  1427. ascii_err_missing1e:    dc.b    13,10
  1428.             dc.b    ' Missing:    ',0
  1429. ascii_err_missing2e:    dc.b    ' -> [error]',0
  1430.  
  1431. ascii_err_missing1w:    dc.b    13,10
  1432.             dc.b    ' Missing:    ',0
  1433. ascii_err_missing2w:    dc.b    ' -> [warning]',0
  1434.  
  1435. ascii_err_trunc1:    dc.b    13,10
  1436.             dc.b    ' Truncated:    ',0
  1437. ascii_err_trunc2:    dc.b    ' -> [error]',0
  1438.  
  1439. ascii_err_notex:    dc.b    13,10
  1440.             dc.b    ' WAD contains no [textures] -> [warning]',0
  1441. ascii_err_noflats:    dc.b    13,10
  1442.             dc.b    ' WAD contains no [flats] -> [warning]',0
  1443. ascii_err_nopatches:    dc.b    13,10
  1444.             dc.b    ' WAD contains no [patches] -> [warning]',0
  1445. ascii_err_pnodes:    dc.b    13,10
  1446.             dc.b    ' Could not allocate space for [nodes] -> [error]',0
  1447. ascii_err_memory:    dc.b    13,10
  1448.             dc.b    ' Could not allocate space for [arrays] -> [error]',0
  1449. ascii_err_openwad:    dc.b    13,10
  1450.             dc.b    ' Could not find & open WAD file -> [error]',0
  1451. ascii_err_badwad:    dc.b    13,10
  1452.             dc.b    ' The specified IWAD is not compatible -> [error]',0
  1453. ascii_err_badpwad:    dc.b    13,10
  1454.             dc.b    ' The specified PWAD is not compatible -> [error]',0
  1455.  
  1456. *-------------------------------------------------------*
  1457. *    Leveldata search details            *
  1458. *-------------------------------------------------------*
  1459.  
  1460. ascii_things:        dc.b    'things',0
  1461. ascii_linedefs:        dc.b    'linedefs',0
  1462. ascii_sidedefs:        dc.b    'sidedefs',0
  1463. ascii_vertexes:        dc.b    'vertexes',0
  1464. ascii_segs:        dc.b    'segs',0
  1465. ascii_ssectors:        dc.b    'ssectors',0
  1466. ascii_nodes:        dc.b    'nodes',0
  1467. ascii_sectors:        dc.b    'sectors',0
  1468. ascii_reject:        dc.b    'reject',0
  1469. ascii_blockmap:        dc.b    'blockmap',0
  1470.  
  1471. ascii_colormap:        dc.b    'colormap',0
  1472. ascii_playpal:        dc.b    'playpal',0
  1473.  
  1474. *-------------------------------------------------------*
  1475.             bsslong
  1476. *-------------------------------------------------------*
  1477.  
  1478. wad_diroffset:        ds.l    1
  1479. pwad_diroffset:        ds.l    1
  1480.  
  1481. wad_directory:        ds.l    1
  1482. wad_entries:        ds.l    1
  1483.  
  1484. pwad_directory:        ds.l    1
  1485. pwad_entries:        ds.l    1
  1486.  
  1487. all_directory:        ds.l    1
  1488. all_entries:        ds.l    1
  1489.  
  1490. *-------------------------------------------------------*
  1491.  
  1492. wad_mentries:        ds.l    1        ; wad search & retrieve variables
  1493. wad_mdirectory:        ds.l    1
  1494. wad_searchfield:    ds.l    1
  1495.  
  1496.  
  1497. field_ptr:        ds.l    1
  1498.  
  1499. Seg_Array        ds.l    1        ; leveldata array pointers
  1500. Side_Array        ds.l    1
  1501. Line_Array        ds.l    1
  1502. Node_Array        ds.l    1
  1503. PNode_Array        ds.l    1
  1504. Sector_Array        ds.l    1
  1505. Vertex_Array        ds.l    1
  1506. SSector_Array        ds.l    1
  1507. Thing_Array        ds.l    1
  1508.  
  1509. colormap_ptr:        ds.l    1        ; palette & colourmap pointers
  1510. playpal_ptr:        ds.l    1
  1511.  
  1512. level_fields:        ds.l    field_count+1    ; space for level search information
  1513.  
  1514. switch_space:        ds.b    8+1
  1515. cli_space:        ds.b    255+1
  1516.  
  1517. wad_header:        ds.b    wh_len        ; space for IWAD header
  1518. wad_handle:        ds.w    1        ; IWAD handle
  1519.  
  1520. pwad_header:        ds.b    wh_len        ; space for PWAD header
  1521. pwad_handle:        ds.w    1        ; PWAD handle
  1522.  
  1523. fields_left:        ds.w    1        ; leveldata field count
  1524.  
  1525. num_reserved:        ds.w    1
  1526. num_required:        ds.w    1
  1527.  
  1528. NumThings:        ds.w    1        ; various array sizes
  1529. NumSegs:        ds.w    1
  1530. NumLines:        ds.w    1
  1531. NumSides:        ds.w    1
  1532. NumVertices:        ds.w    1
  1533. NumSSectors:        ds.w    1
  1534. NumNodes:        ds.w    1
  1535. NumSectors:        ds.w    1
  1536.  
  1537. *-------------------------------------------------------*
  1538.             txtlong
  1539. *-------------------------------------------------------*
  1540.  
  1541.